CREATE TRIGGER TGCHITIETPHIEUNHAP_01 ON CHITIETPHIEUNHAP AFTER INSERT,UPDATE
AS
BEGIN
	DECLARE @MASACH VARCHAR(50) 
	SET @MASACH   = (SELECT MASACH FROM inserted)
	DECLARE @COUNT INT
	SET @COUNT =(SELECT SoLuong FROM inserted WHERE @MASACH = MaSach)
	UPDATE Sach SET SoLuong =  (SoLuong + @COUNT) WHERE @MASACH = MaSach
END
	